<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #canvas1 {
      border: 1px solid blue;
    }
  </style>
</head>

<body>
  <canvas id="canvas1" width="1152" height="1224"></canvas>
  <!-- <canvas id="canvas1" width="800" height="800"></canvas> -->
</body>

<script>

  // 获取画布
  let canvas = document.getElementById('canvas1')
  // 获取画笔
  let ctx = canvas.getContext('2d')

  let img = new Image()
  img.src = './123.jpg'


  // 图片载入后再进行绘制 否则绘制不到
  img.onload = function () {
    // 绘制图像
    // ctx.drawImage(图片对象，裁剪坐标x, 裁剪坐标y, 裁剪宽度， 裁剪高度，x位置，y位置, 图片宽度， 图片高度)
    ctx.drawImage(img, 0, 0, 1152, 1224)
  }

</script>

</html>